package com.example.minademo.service.impl;

import com.example.minademo.dao.UserDao;
import com.example.minademo.entity.User;
import com.example.minademo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao mUserDao;

    @Override
    public User findUserById(Integer id) {
        if(!mUserDao.findById(id).isPresent()){
            return null;
        }
        return mUserDao.findById(id).get();
    }

    @Override
    public boolean saveUser(User user) {
        return mUserDao.save(user) != null;
    }

    @Override
    public User findByNameAndPassword(String name, String password) {
        return mUserDao.findByNameAndAndPassword(name,password);
    }

    @Override
    public User findUserByName(String name) {
        return mUserDao.findUserByName(name);
    }


}
